#ifndef QWAVEWIDGET_H
#define QWAVEWIDGET_H

#include "qlineitem.h"

#include <QGraphicsView>
#include <QGraphicsScene>
#include <QRubberBand>

enum enTrendState
{
    TS_NONE,
    TS_HAS_DATA
};


class QWaveWidget : public QGraphicsView
{
    Q_OBJECT
public:
    explicit QWaveWidget(QWidget *parent = 0);
    ~QWaveWidget();

    int x_count();
    int x_start();
    double get_min(int line);
    double get_max(int line);

    void    set_visible(int line,bool visible);
    void    set_color(int line,const QColor& color);

    void    set_value(double *value,int line_count,int data_count);

    void    set_LButton_type(int type);

    void    scale(double l,double t,double r,double b);
    void    scale(double x,double y);
    void    scale(const QRect &re);

    void    trend_move(int x,double y);

    void    reset();

    void    clear();

    void    set_status(enTrendState status);
    enTrendState get_status();
protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);

    void paintEvent(QPaintEvent *);

    void resizeEvent(QResizeEvent *);
protected:
    friend class QLineItem;
signals:
    void status_changed(int status);
    void need_update();
    void clicked_value(const QString &text1,const QString &text2,const QString &text3,const QString &text4);
public:
    QLineItem       *m_data_item[4];
    QRubberBand     *m_rubber;
    QPoint           m_rubber_pos;
    int             m_draw_point;
    int             m_lbutton_type;
    bool            m_is_move;
    enTrendState    m_trend_state;

    int             m_start_x;
    int             m_count_x;
    int             m_tatal_count;
    int             m_line_total;
    QImage          m_image;
    QGraphicsScene  *m_scene;
    double          m_scale_x;
    double          m_scale_y;

    double          m_y_t;
    double          m_y_d;
};

#endif // QWAVEWIDGET_H
